package com.weharvest.edu.converter;

import com.weharvest.edu.entity.BackstageMenu;
import com.weharvest.edu.view.BackstageRoleAndMenuAndPermissionView;
import org.springframework.beans.BeanUtils;

import java.util.List;
import java.util.stream.Collectors;

public class BackstageMenu2OBackstageMenuAndPermissionView {
    /**
     * 单独转换
     * @parame
     * @return
     */
    public static BackstageRoleAndMenuAndPermissionView converter(BackstageMenu backstageMenu){
        BackstageRoleAndMenuAndPermissionView backstageMenuAndPermissionView=
                new BackstageRoleAndMenuAndPermissionView();
        BeanUtils.copyProperties(backstageMenu,backstageMenuAndPermissionView);
        return backstageMenuAndPermissionView;
    }

    /**
     * 集合转换
     * @param
     * @return
     */
    public static List<BackstageRoleAndMenuAndPermissionView> converter(List<BackstageMenu>backstageMenuList){
        List<BackstageRoleAndMenuAndPermissionView>backstageMenuAndPermissionViewList=
                backstageMenuList.stream().map(e -> converter(e)).collect(Collectors.toList());
        return backstageMenuAndPermissionViewList;
    }
}
